package org.logan.sample.web.main.action.system;

import javax.servlet.http.HttpServletRequest;
import org.logan.sample.db.model.SysUser;
import org.logan.sample.web.base.common.Pager;
import org.logan.sample.web.main.action.common.BaseController;
import org.logan.sample.web.main.service.system.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Desc：系统用户控制层
 * @Title：SysUserContrller
 * @address: http://www.liveneo.com.cn/
 * @author: zhaoyy
 * @version: 1.0 
 * @date: 2016年11月2日 上午11:37:15
 */
@Controller
public class SysUserController extends BaseController {
    @Autowired
    private SysUserService sysUserService;

    /**
     * @Desc: 初始化页面
     * @Author: zhaoyy 2016年11月2日 下午1:46:29
     * @param model
     * @return
     */
    @RequestMapping(value = "/admin/sys/user")
    public String initPage() {
        return "system/user/list";
    }

    /**
     * @Desc: 用户列表
     * @Author: zhaoyy 2016年11月2日 下午5:29:02
     * @param request
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/user/list.html")
    public Object list(HttpServletRequest request) {
        Pager pager = createPager(request);
        pager.addParam("cfgId", getRequestParams(String.class, request, "cfgId"));
        pager.addParam("status", getRequestParams(Integer.class, request, "status"));
        pager.addParam("parentCfg", getRequestParams(String.class, request, "parentCfg"));
        sysUserService.queryPager(pager);
        return getGridData(pager);
    }

    @ResponseBody
    @RequestMapping(value = "/user.html")
    public String user(HttpServletRequest request) {
        SysUser su = sysUserService.queryUserByAccount("admin@sample.org");
        System.out.println(su.getUserMobile());
        return su.getUserMobile();
    }
}
